CREATE TABLE [dbo].[Activity]
(
[Id] [int] NOT NULL IDENTITY(1, 1),
[SessionId] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[UserId] [int] NOT NULL,
[Ip] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
[DateLogin] [datetime] NULL,
[DateLogout] [datetime] NULL,
[Description] [nvarchar] (150) COLLATE SQL_Latin1_General_CP1_CI_AS NULL
) ON [PRIMARY]
CREATE UNIQUE NONCLUSTERED INDEX [IX_Activity] ON [dbo].[Activity] ([SessionId]) ON [PRIMARY]

GO
EXEC sp_addextendedproperty N'MS_Description', N'UserId là khóa ngoại tham chiếu từ  bảng UserAccount', 'SCHEMA', N'dbo', 'TABLE', N'Activity', 'CONSTRAINT', N'FK_Activity_UserAccount'
GO

ALTER TABLE [dbo].[Activity] ADD
CONSTRAINT [FK_Activity_UserAccount] FOREIGN KEY ([UserId]) REFERENCES [dbo].[UserAccount] ([Id])
GO
ALTER TABLE [dbo].[Activity] ADD CONSTRAINT [PK_Activity] PRIMARY KEY CLUSTERED  ([Id]) ON [PRIMARY]
GO
